/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.common.constant.rules;


import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;

/**
 * 重要数据安全需求关联指标规则
 * @author zpy
 * @version 1.0.0
 */
public enum KeyDataReqTargetRule {
    /**机密性**/
    CONFIDENTIALITY("机密性","重要数据传输机密性","重要数据存储机密性"),
    /**完整性**/
    INTEGRITY("完整性","重要数据传输完整性","重要数据存储完整性"),
    /**传输机密性**/
    TRANSPORT_CONFIDENTIALITY("传输机密性","重要数据传输机密性"),
    /**存储机密性**/
    STORE_CONFIDENTIALITY("存储机密性","重要数据存储机密性"),
    /**传输完整性**/
    TRANSPORT_INTEGRITY("传输完整性","重要数据传输完整性"),
    /**存储完整性**/
    STORE_INTEGRITY("存储完整性","重要数据存储完整性"),
    /**不可否认性**/
    NON_REPUDIATION("不可否认性","不可否认性");

    private final String name;
    private final List<String> targetNames;

    KeyDataReqTargetRule(String reqName,String... targetNames) {
        this.name = reqName;
        this.targetNames = Arrays.asList(targetNames);
    }

    public static KeyDataReqTargetRule fromName(String name){
        if(StringUtils.isEmpty(name)){
            return null;
        }
        KeyDataReqTargetRule data = null;
        for(KeyDataReqTargetRule item : KeyDataReqTargetRule.values()){
            if(StringUtils.equals(item.name,name)){
                data = item;
                break;
            }
        }
        return data;
    }

    public String getName(){
        return this.name;
    }

    public List<String> getTargetNames(){
        return this.targetNames;
    }
}